# -*- coding:utf-8 -*-

'''
PROJECT_NAME : auth_demo
file    : app2
author  : 1032162439@qq.com
date    : 2022-09-08 21:18
IDE     : PyCharm
'''
from flask import Flask, session

app = Flask(__name__)

app.secret_key = 'secret key string'


@app.route('/set_session')
def set_session():
    """
    设置session
    :return:
    """
    session['user'] = 'zhangsan'
    return 'set session success!'


@app.route('/clear_session')
def clear_session():
    """
    清理session
    :return:
    """
    session.clear()
    return 'clear session success!'


@app.route('/source')
def source():
    """
    资源
    :return:
    """
    if not session.get('user'):
        return '无权访问'
    return '有权访问'


if __name__ == '__main__':
    app.run(debug=True)
